package com.fzg.controller;

import com.fzg.common.enums.ResponseWrapper;
import com.fzg.service.SearchService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * create by fzg
 * 2022/12/22 9:16
 * 搜索菜单控制
 */

@RestController
@RequestMapping("/search")
public class SearchController {

    private final SearchService searchService;

    public SearchController(SearchService searchService) {
        this.searchService = searchService;
    }

    /**
     * 通过关键字搜索获取菜谱
     * @param searchKey 关键字
     * @return ResponseWrapper
     */
    @GetMapping("/getFoodSteps")
    public ResponseWrapper getDataBySearchKey(@RequestParam String searchKey){
        return searchService.getDataBySearchKey(searchKey);
    }

    /**
     * 获取随机菜谱
     * @return ResponseWrapper
     */
    @GetMapping("/getRandomRecipe")
    public ResponseWrapper getRandomRecipe(){
        return searchService.getRandomRecipe();
    }


    /**
     * @name 方法名：getRandomSwiper
     * @description todo: 随机获取5张轮播图
     *
     * @return ResponseWrapper
     * @date 2022/12/26 13:15
     * @author fzg
     **/
    @GetMapping("/getRandomSwiper")
    public ResponseWrapper getRandomSwiper(){
        return searchService.getRandomSwiper();
    }

}
